package com.insigma.business.qrcode.job.consumer.impl;

import com.insigma.business.qrcode.common.converter.JobCandidateResumeProviderConverter;
import com.insigma.business.qrcode.common.util.BizCheckUtil;
import com.insigma.business.qrcode.common.util.ResponseUtils;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import com.insigma.business.qrcode.job.consumer.CandidateResumeConsumer;
import com.insigma.business.qrcode.job.dto.JobCandidateResumeDTO;
import com.insigma.business.qrcode.job.entity.JobCandidateResumeDO;
import com.insigma.business.qrcode.job.service.JobCandidateResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CandidateResumeConsumerImpl implements CandidateResumeConsumer {
    @Autowired
    private JobCandidateResumeService jobCandidateResumeService;

    @Override
    public BaseResponse<JobCandidateResumeDTO> getMyResume(String userId) {
        BizCheckUtil.checkNotBlank(userId, "userId不能为空");

        JobCandidateResumeDO jobCandidateResumeDO = jobCandidateResumeService.getByCandidateId(userId);
        final JobCandidateResumeDTO remoteObj = JobCandidateResumeProviderConverter.convertResponseDO2DTO(jobCandidateResumeDO);
        if (remoteObj != null) {
            remoteObj.build();
        }
        return ResponseUtils.buildSuccessResponse(remoteObj);
    }
}
